home *** CD-ROM | disk | FTP | other *** search
/ Over 1,000 Windows 95 Programs / Over 1000 Windows 95 Programs (Microforum) (Disc 1).iso / 1249 / lister.t < prev    next >
Text File  |  1997-04-18  |  973b  |  63 lines

  1. %
  2. %  "lister.t" lists T source programs and adds line numbers
  3. %
  4. %   Sample program for the T Interpreter by:
  5. %
  6. %   Stephen R. Schmitt
  7. %   962 Depot Road
  8. %   Boxborough, MA 01719
  9. %
  10.  
  11. type file_name : string
  12.  
  13. var Main_file_name : file_name
  14. var Main_file : int
  15. var Line_buffer: string
  16.  
  17.  
  18. program
  19.  
  20.     open_main
  21.     process_file
  22.  
  23. end program
  24.  
  25.  
  26. procedure open_main
  27.  
  28.     prompt "main file name:"
  29.     get Main_file_name
  30.  
  31.     Main_file := open( Main_file_name, "r" )
  32.     if Main_file = 0 then
  33.  
  34.         put "ERROR -- File not found: ", Main_file_name
  35.         assert false
  36.  
  37.     end if
  38.  
  39. end procedure
  40.  
  41.  
  42. procedure process_file
  43.  
  44.     var n : int := 0
  45.  
  46.     loop
  47.  
  48.         exit when eof( Main_file) 
  49.         get :Main_file, Line_buffer : *
  50.         incr n
  51.         put n:3, ": ", Line_buffer 
  52.         Line_buffer := ""
  53.     
  54.     end loop
  55.  
  56.     if close( Main_file ) = 0 then
  57.  
  58.         put "file close error"
  59.  
  60.     end if
  61.  
  62. end procedure
  63.